#!/usr/bin/env python3
# -*- coding: UTF-8 -*-
# @Date : 2024/6/2 17:06
# @Author : water
import redis

# 连接到Redis
r = redis.Redis(host='172.22.1.197', port=6379, db=13, password="Sxxc@2024")

# 打开大文件
# with open('H:\da1out.txt', 'r') as file:
with open('C:/Users/sanduo/Desktop/dzda_stwj_2024-05-24.txt', 'r', encoding='utf-8') as file:
    for line in file:
        # 假设每行是一个键值对
        if len(line.strip().split(',')) == 2:
            key, value = line.strip().split(',')
            # 使用pipeline批量写入
            pipe = r.pipeline()
            pipe.set(key, value)
            # 执行pipeline
            pipe.execute()
